<style>
.layui-form-pane .layui-form-label{width:auto;}
.layui-form-item{margin-bottom: 0px;}
.separate{color:red;margin:0px 4px;}
.true-data{color:green;}
.layui-elem-field legend{font-size:14px;}
.layui-colla-item{border-bottom:1px solid #eeeeee;}
.layui-colla-title{background-color:#5FB878;}
.layui-colla-title-warn{background-color:#FFB800;}
.layui-colla-title-unpull{background-color:#01AAED;}
@media screen and (max-width: 600px) {
	.page-body,.page-tab-content,.layui-colla-content{padding:0px;}
	.layui-table td, .layui-table th{padding:5px 2px; text-align:center;}
	.fixed-bar .layui-input {width:80px;}
}
.layui-form-label,.layui-input-inline{padding:3px 5px}
.blue{margin-right:15px }
.C-S{background-color: #ccccff;}
.C-M{background-color: #ffa;}
.C-L{background-color: #ccffcc}
.C-XL{background-color: #ffffcc}
.C-XXL{background-color: #ffcccc}
.C-XXXL{background-color:#ccccff}
.C-XS{background-color: #cccccc}
.C-XXS{background-color:#999900}
.C-XXXS{background-color: #99ff99}
.C-1XL{background-color: #ffa;}
.C-2XL{background-color: #eeeeee;}
.C-3XL{background-color: #ffa;}
.C-4XL{background-color: #ccff99;}
.C-5XL{background-color: #ffa;}
.button_selected{background-color:#1E9FFF;}
.button_notselect{background-color:#fff;}
</style>

<div class="fixed-bar">
	<form class="layui-form layui-form-pane fixed-bar-form" action="{:url()}" method="get">
		<div class="layui-form-item">	
			<div class="layui-inline" style="display:inline-block;">
				<label class="layui-form-label">订单号</label>
				<div class="layui-input-inline" style="margin:0px;display:inline-block;">
					<input type="text" id="client_ordernum" name="client_ordernum" value="{$clientOrdernum}" lay-verify="" placeholder="订单号" class="layui-input">
				</div>
			</div>
			<div class="layui-inline" style="display:inline-block;">
                <button type="submit" class="layui-btn" id="demo1" lay-submit="" lay-filter="demo1">搜索</button>
			</div>
		</div>
	</form>
</div>

<div class="layui-row">
	{if $error != ''}
		<div class="mt10 pl20 pb50 red"><i class="layui-icon layui-icon-face-cry" style="font-size: 30px;"></i> {$error}</div>
	{elseif $clientOrdernum != '' && empty($omcInfo) /}
			
		<table class="layui-table">
			<tr>
				<td><a href="#" orderid="{$oInfo['id']}" class="layui-btn layui-btn-sm layui-btn-primary printrCutPackageLabel">包数打标</a>
				{if env('env_site') == 'riwei' }<a href="#" orderid="{$oInfo['id']}" class="layui-btn layui-btn-sm layui-btn-primary printrCutSizeLabel">扎菲票打印</a>{/if}
                <a href="{:url('print', ['order_id' => $oInfo['id']])}" target="_blank" class="layui-btn layui-btn-sm layui-btn-primary">裁床单打印</a>
        <a href="{:url('stripEdit', ['order_id' => $oInfo['id']])}" class="hisi-iframe layui-btn layui-btn-sm layui-btn-primary" title="编辑" hisi-data="{width: '100%', height: '100%'}">编辑</a>
        {if $oInfo['jinpeng_status']==1}
        <a href="{:url('Order/syncJinpeng',['order_id' => $oInfo['id'],'action'=>'dele'])}" class="layui-btn layui-btn-sm layui-btn-primary hisi-ajax" title="删除金鹏订单">删除金鹏订单</a>
        {else /}
        <a href="{:url('Order/syncJinpeng',['order_id' => $oInfo['id'],'action'=>'add'])}" class="layui-btn layui-btn-sm layui-btn-primary hisi-ajax" title="同步至金鹏">同步至金鹏</a>
        {/if}
        </td>
				<td><button type="button" data-href="{:url('resetOrder', ['order_id' => $oInfo['id']])}" confirm="您确定要执行该操作吗" class="layui-btn layui-btn-sm layui-btn-warm hisi-ajax fr mr10" refresh="true">订单重置</button></td>
			</tr>
			<tr>
				<td style="text-align:center;"><img src="{$sInfo['ori_pic']}" class="lay-pic"></td>
				<td>
					<span class="copy-item">{$clientOrdernum}</span><br>
					<span class="copy-item">{$oInfo['sku']}</span><br>
					{:date('Y-m-d', $oInfo['shipment_time'])}<br>
					床号：<span class="layui-badge layui-bg-blue">{$oInfo['id']}
				</td>
			</tr>
		</table>
		
		<div class="layui-collapse mt10" lay-filter="material-list">
			{foreach $omList as $omKey => $omInfo}
            <form class="layui-form" action="{:url('confirm', ['mid' => $omInfo['mid']])}" method="post" id="form{$omKey}">
			<div class="layui-colla-item">
				<!--+$omInfo['caichuang_strip_dosage']-->
          	<h2 class="layui-colla-title {if $omInfo['caichuang_status']!=3}layui-colla-title-warn{elseif ($omInfo['caichuang_pull_status']==0)/}layui-colla-title-unpull{/if}">面料名称：{$omInfo['mInfo']['name']}<span class="ml10">[客户用量：{$omInfo['customer_dosage']}]</span><span>[实际单件用量：{$omInfo['caichuang_shiji_dosage']}]
                  </span></h2>
				<div class="layui-colla-content {if $mid == $omInfo['mid'] || $mid == 0 && $omKey==0 && $omInfo['caichuang_status'] == 3}layui-show{/if}">
					
					<!-- 唛架信息start -->
					<fieldset class="layui-elem-field {if $omInfo['caichuang_status']!=3}hide{/if}" style="margin-top: 10px;">
						<legend>唛架信息</legend>
						<table class="layui-table">
							<thead>
								<tr>
									<th>尺码</th>
									<th>下单数</th>
									<th>应裁数</th>
									<th>实裁数</th>
									<th>低层件数</th>
									<th>高层件数</th>
								</tr>
							</thead>
							<tbody>
								{foreach $osList as $k => $v}
								<tr>
									<td>{$v['size_name']}</td>
									<td>{$v['order_count']}</td>
									<td>{:arrayGet($v['wheat_height_count_detail'], $omInfo['mid'], 0)*$omInfo['caichuang_wheat_height'] + arrayGet($v['wheat_low_count_detail'], $omInfo['mid'], 0)*$omInfo['caichuang_wheat_low']}</td>
									<td>{:arrayGet($v['wheat_height_count_detail'], $omInfo['mid'], 0)*$omInfo['caichuang_t_wheat_height'] + arrayGet($v['wheat_low_count_detail'], $omInfo['mid'], 0)*$omInfo['caichuang_t_wheat_low']}</td>
									<td>
										{if $omInfo['caichuang_standard'] == 1}
											<div class="layui-row" style="line-height:38px;">
												<div class="layui-col-xs6">{:arrayGet($v['wheat_low_count_detail'], $omInfo['mid'], 0)}</div>
												<div class="layui-col-xs6">
													{if $omInfo['caichuang_pull_status'] == 0}
														<input type="number" class="layui-input" name="wheat_low_bundle_detail[{$v['mid']}]" lay-verify="mimoint" value="{:filterZero(arrayGet($v['wheat_low_bundle_detail'], $omInfo['mid'], 0))}" value="">
													{else /}
														<span class="separate">/</span>{:filterZero(arrayGet($v['wheat_low_bundle_detail'], $omInfo['mid'], 0))}
													{/if}
												</div>
											</div>
										{else /}
											{:arrayGet($v['wheat_low_count_detail'], $omInfo['mid'], 0)}
										{/if}
									</td>
									<td>
										{if $omInfo['caichuang_standard'] == 1}
											<div class="layui-row" style="line-height:38px;">
												<div class="layui-col-xs6">{:arrayGet($v['wheat_height_count_detail'], $omInfo['mid'], 0)}</div>
												<div class="layui-col-xs6">
													{if $omInfo['caichuang_pull_status'] == 0}
														<input type="number" class="layui-input" name="wheat_height_bundle_detail[{$v['mid']}]" lay-verify="mimoint" value="{:filterZero(arrayGet($v['wheat_height_bundle_detail'], $omInfo['mid'], 0))}" value="">
													{else /}
														<span class="separate">/</span>{:filterZero(arrayGet($v['wheat_height_bundle_detail'], $omInfo['mid'], 0))}
													{/if}
												</div>
											</div>
										{else /}
											{:arrayGet($v['wheat_height_count_detail'], $omInfo['mid'], 0)}
										{/if}
									</td>
								</tr>
								{/foreach}
								
								<tr>
									<td>总数</td>
									<td>{$oInfo['quantity']}</td>
									<td>{$omInfo['yingcai_count']}</td>
									<td>{$omInfo['shicai_count']}</td>
									<td>
										{php}
											$num = 0;
											foreach($osList as $k => $v){
												$num += arrayGet($v['wheat_low_count_detail'], $omInfo['mid'], 0);
											}
											echo $num;
										{/php}
									</td>
									<td>
										{php}
											$num = 0;
											foreach($osList as $k => $v){
												$num += arrayGet($v['wheat_height_count_detail'], $omInfo['mid'], 0);
											}
											echo $num;
										{/php}
									</td>
								</tr>
								
								<tr>
									<td colspan="6">捆条宽度：{$omInfo['caichuang_strip_width']}米，捆条单件用量：{$omInfo['caichuang_strip_dosage']}米，
									唛架低层：{$omInfo['caichuang_wheat_low_length']}米，
									唛架高层：{$omInfo['caichuang_wheat_height_length']}米</td>
								</tr>
							</tbody>
						</table>
					</fieldset>
					<!-- 唛架信息end -->
					
					<!-- 裁剪执行信息start -->
					<a id="m{$omInfo['mid']}"></a>
					<fieldset class="layui-elem-field {if $omInfo['caichuang_status']!=3}hide{/if}" style="margin-top: 10px;">
						<legend>裁剪执行信息</legend>
						<table class="layui-table">
							<thead>
								<tr>
									<th>布号</th>
									<th>米数</th>
									<th>低层数</th>
									<th>高层数</th>
									<th>捆条</th>
									<th>布头</th>
								</tr>
							</thead>
							<tbody>
								{foreach $omInfo['omiList'] as $v}
								<tr>
									<td><a href="{:url('realData', ['id' => $v['id'], 'type' => 0])}#cn{$v['cloth_num']}" class="hisi-iframe" hisi-data="{width: 'auto', height: '90%'}" title="裁剪录入-{$v['cloth_num_full']}" style="text-decoration:underline;">{$v['cloth_num_full']}</a></td>
									<td>{$v['length']}</td>
									<td>{:filterZero($v['caichuang_wheat_low'])}<span class="separate">/</span><span class="true-data">{:filterZero($v['caichuang_t_wheat_low'])}</span></td>
									<td>{:filterZero($v['caichuang_wheat_height'])}<span class="separate">/</span><span class="true-data">{:filterZero($v['caichuang_t_wheat_height'])}</span></td>
									<td>{:filterZero($omInfo['caichuang_strip_dosage']*$omInfo['yingcai_count']*1.1)}<span class="separate">/</span><span class="true-data">{:filterZero($v['caichuang_t_strip'])}</span></td>
									<td>{:filterZero($v['caichuang_neadend'])}<span class="separate">/</span><span class="true-data">{:filterZero($v['caichuang_t_neadend'])}</span></td>
								</tr>
								{/foreach}
								
								{if !empty($omInfo['mscInfo']) }
								<tr>
									<td><a href="{:url('realData', ['id' => $omInfo['mscInfo']['id'], 'type' => 1])}#msc" class="hisi-iframe" hisi-data="{width: 'auto', height: '90%'}" title="裁剪录入-库存面料">库存面料</a></td>
									<td>{$omInfo['mscInfo']['length']}</td>
									<td>{:filterZero($omInfo['mscInfo']['caichuang_wheat_low'])}<span class="separate">/</span><span class="true-data">{:filterZero($omInfo['mscInfo']['caichuang_t_wheat_low'])}</span></td>
									<td>{:filterZero($omInfo['mscInfo']['caichuang_wheat_height'])}<span class="separate">/</span><span class="true-data">{:filterZero($omInfo['mscInfo']['caichuang_t_wheat_height'])}</span></td>
									<td>{:filterZero($omInfo['caichuang_strip_dosage']*$omInfo['yingcai_count']*1.1)}<span class="separate">/</span><span class="true-data">{:filterZero($omInfo['mscInfo']['caichuang_t_strip'])}</span></td>
									<td>{:filterZero($omInfo['mscInfo']['caichuang_neadend'])}<span class="separate">/</span><span class="true-data">{:filterZero($omInfo['mscInfo']['caichuang_t_neadend'])}</span></td>
								</tr>
								{/if}
								<tr>
									<td>开单采购总米数</td>
									<td>{$omInfo['billing_caigou_count']}</td>
									<td>&nbsp;</td>
								  <td>&nbsp;</td>
								  <td>&nbsp;</td>
								  <td>&nbsp;</td>
								</tr>
								<tr>
									<td>裁前总计</td>
									<td>{:array_sum(array_column($omInfo['omiList'], 'length'))+arrayGet($omInfo['mscInfo'], 'length', 0)-$omInfo['return_length']}
                                    {php}$before_cut_total=array_sum(array_column($omInfo['omiList'], 'length'))+arrayGet($omInfo['mscInfo'], 'length', 0)-$omInfo['return_length'];{/php}
                                    <input type="hidden" name="before_cut_total" id="before_cut_total{$omInfo['mid']}" value="{$before_cut_total}"></td>
									<td>{:filterZero($omInfo['caichuang_wheat_low'])}</td>
									<td>{:filterZero($omInfo['caichuang_wheat_height'])}</td>
									<td>{:filterZero($omInfo['caichuang_strip_dosage']*$omInfo['yingcai_count']*1.1)}</td>
									<td>{:filterZero($omInfo['caichuang_neadend'])}</td>
								</tr>
								<tr>
									<td>裁后总计</td>
									<td>
										<!-- 裁后米数=（实际拉布总数（高层）X 唛架高层 米长） + （实际拉布总数（低层）X唛架低层 米长）+布头总计+捆条总计+（（实际拉布总数（高层）+实际拉布总数（低层））*0.06） -->
										{php}$heightTotal = array_sum(array_column($omInfo['omiList'], 'caichuang_t_wheat_height'))+arrayGet($omInfo['mscInfo'], 'caichuang_t_wheat_height', 0);{/php}
										{php}$lowTotal = array_sum(array_column($omInfo['omiList'], 'caichuang_t_wheat_low'))+arrayGet($omInfo['mscInfo'], 'caichuang_t_wheat_height', 0);{/php}
										{php}$neadendTotal = array_sum(array_column($omInfo['omiList'], 'caichuang_t_neadend'))+arrayGet($omInfo['mscInfo'], 'caichuang_t_neadend', 0);{/php}
										{php}$stripTotal = array_sum(array_column($omInfo['omiList'], 'caichuang_t_strip'))+arrayGet($omInfo['mscInfo'], 'caichuang_t_strip', 0);{/php}
                                        {php}$shicaiCount=array_sum(array_column($osList, 'shicai_count'));{/php}
                                        {php}$allStripDosage=$omInfo['caichuang_strip_dosage']*$shicaiCount;{/php}
										{:round(($heightTotal*$omInfo['caichuang_wheat_height_length']) + ($lowTotal*$omInfo['caichuang_wheat_low_length']) + $neadendTotal + $stripTotal + $allStripDosage + ($heightTotal+$lowTotal)*0.06, 2)}
                                        {php}$cut_real_total=round(($heightTotal*$omInfo['caichuang_wheat_height_length']) + ($lowTotal*$omInfo['caichuang_wheat_low_length']) + $neadendTotal + $stripTotal + $allStripDosage + ($heightTotal+$lowTotal)*0.06, 2);{/php}
                                        <input type="hidden" name="cut_real_total" id="cut_real_total{$omInfo['mid']}" value="{$cut_real_total}">
                                        <input type="hidden" name="oddments_confirm" id="oddments_confirm{$omInfo['mid']}" value="none">									</td>
									<td>{:filterZero($lowTotal)}</td>
									<td>{:filterZero($heightTotal)}</td>
									<td>{:filterZero($stripTotal)}</td>
									<td>{:filterZero($neadendTotal)}</td>
								</tr>
								<tr>
									<td>备注</td>
									<td colspan="5">
										{foreach $omInfo['omiList'] as $v}
											{if $v['caichuang_remark'] != ''}
											{$v['cloth_num_full']}：{$v['caichuang_remark']}<br>
											{/if}
										{/foreach}
										{if !empty($omInfo['mscInfo']) && $omInfo['mscInfo']['caichuang_remark']!='' }
											库存面料：{$omInfo['mscInfo']['caichuang_remark']}
										{/if}									</td>
								</tr>
							</tbody>
						</table>
						
  <div class="layui-row layui-col-space5 mb20 pb10 {if $omInfo['caichuang_status']!=3}hide{/if}">
			                <div class="layui-col-xs3" style="line-height:30px; text-align:center;">实量布封</div>
			                <div class="layui-col-xs3" style="height:30px; line-height: 30px;">
			                  {$omInfo['true_fabric_width']}
			                </div>
			                <div class="layui-col-xs3" style="line-height:30px; text-align:center;">实裁布封</div>
			                <div class="layui-col-xs3" >
			                    <input type="text" name="caichuang_fabric_width" value="{$omInfo['caichuang_fabric_width']}" {if $omInfo["caichuang_pull_status"] == 1}readonly{/if} autocomplete="off" lay-verify="mimonumber" class="layui-input" style="height:30px;">
			                </div>
			                <div class="layui-col-xs6" style="text-align:center;">
			                  {if $omInfo['caichuang_pull_status'] == 0}
                              <button type="button" class="layui-btn layui-btn-sm layui-btn-normal submit222333" btn="firstbtn" formindex="{$omKey}"
									  id="formSubmit-{$omInfo['mid']}" lay-submit="" data-mid="{$omInfo['mid']}"  lay-filter="Submit222333">拉布确认</button>
			                  {else /}
			                    <button type="button" class="layui-btn layui-btn-sm layui-btn-radius">已完成</button>
			                  {/if}
			                  <button type="button" data-href="{:url('resetItem', ['mid' => $omInfo['mid']])}" confirm="您确定要执行该操作吗" class="layui-btn layui-btn-sm layui-btn-primary hisi-ajax" refresh="true">返回重置</button> <a href="{:url('purchasingV3/returnClothnum')}?mid={$omInfo.mid}&from=caichuang" title="退料" class="layui-btn layui-btn-sm layui-btn-normal hisi-iframe" hisi-data="{width: '800px', height: '500px', endRefresh:'layer'}">退料</a>
                              {if $omInfo['material_stock_id'] >0}
                              <a href="{:url('materialStockLabel')}?material_stock_id={$omInfo['material_stock_id']}" class="layui-btn layui-btn-primary layui-btn-sm" target="_blank">打印余料库存面单</a>
                              {/if}
                               &nbsp;<span id="oddments_confirm_result{$omInfo['mid']}"></span>
			                 </div>
						</div>
					</fieldset>
					<!-- 裁剪执行信息end -->
				</div>
			</div>
            <input type="hidden" name="have_oddments" id="have_oddments{$omInfo['mid']}" value="0" />
            <input type="hidden" name="oddments_meters" id="oddments_meters{$omInfo['mid']}" value="" />
            <input type="hidden" name="storeHouse" id="storeHouse{$omInfo['mid']}" value="" />
            <input type="hidden" name="stock_position" id="stock_position{$omInfo['mid']}" value="" />
			</form>
			{/foreach}
		</div>
    <!--合裁-->
    {elseif($clientOrdernum != '' && !empty($omcInfo)) /}
    <input id="omc-id" hidden="true"  value="{$omcInfo['id']}"/>
    <div class="layui-collapse" lay-filter="material-list">
        <form class="layui-form" action="" method="post" id="form2">
            <label class="layui-form-label">扎数信息</label>
            <div class="layui-inline" style="display:inline-block;">
				<label class="layui-form-label">总扎数</label>
				<div class="layui-input-inline" style="margin:0px;display:inline-block;">
                    <input type="text" id="allZhaCount" cookie="allZhaCount{$omcInfo['id']}" name="allZhaCount" value="" lay-verify="" placeholder="请输入" class="layui-input cookieSave">
				</div>
			</div>
            <div class="layui-inline" style="display:inline-block;">
				<label class="layui-form-label">总件数</label>
				<div class="layui-input-inline" style="margin:0px;display:inline-block;">
                    <input type="text" id="allJianCount" cookie="allJianCount{$omcInfo['id']}" name="allJianCount" value="" lay-verify="" placeholder="请输入" class="layui-input cookieSave">
				</div>
			</div>
            <a href="{:url('addMcZha', ['client_ordernum' => $clientOrdernum])}" title="填写扎数" class="hisi-iframe layui-btn layui-btn-normal layui-btn-sm" hisi-data="{width: '70%', height: '70%'}">添加扎数</a>
            
            {if condition="env('jinpeng_api_status') eq 1"}
	            {if($oInfo['jinpeng_status']==1) /}
	            <a class="layui-btn layui-btn-normal layui-btn-sm" lay-submit="" id="zhaEdit" lay-filter="zhaEdit">删除金鹏订单</a>
	            <input name="action" value="dele" hidden="true">
	            {else}
	            <a class="layui-btn layui-btn-normal layui-btn-sm" lay-submit="" id="zhaEdit" lay-filter="zhaEdit">保存并同步金鹏</a>
	            <input name="action" value="add" hidden="true">
	            {/if}
            {/if}
			{if condition="env('jinpeng_api_status') eq 0"}
				{if($oInfo['jinpeng_status']==1) /}
				<a class="layui-btn layui-btn-normal layui-btn-sm" lay-submit="" id="zhaEdit" lay-filter="zhaEdit">删除订单</a>
				<input name="action" value="dele" hidden="true">
				{else}
				<a class="layui-btn layui-btn-normal layui-btn-sm" lay-submit="" id="zhaEdit" lay-filter="zhaEdit">保存订单</a>
				<input name="action" value="add" hidden="true">
				{/if}
			{/if}
            
            <a href="{:url('omcPrint')}?client_ordernum={$clientOrdernum}" target="_blank" class="layui-print layui-btn-normal layui-btn layui-btn-sm">打印</a>
            <a href="{:url('dosageEdit')}?client_ordernum={$clientOrdernum}" hisi-data="{width: '70%', height: '70%'}"  class="hisi-iframe layui-print layui-btn-normal layui-btn layui-btn-sm">用量编辑</a>
			{if env('env_site') == 'riwei' }<a href="#" orderid="{$oInfo['id']}" class="layui-btn layui-btn-sm layui-btn-primary printrCutSizeLabel">扎菲票打印</a>{/if}
            <div class="layui-form zhahao-list">
                {if(!empty($ouList)) /}
                <table class="layui-table">
                    <thead>
                        <tr>
                            <th>订单号</th>
                            <th>床号</th>
                            <th>尺码</th>
                            <th>扎号</th>
                            <th>件数</th>
                            {if condition="env('jinpeng_api_status') eq 1"}
                            <th>已同步数量</th>
                            <th>状态</th>
                            <th>操作</th>
                            {/if}
                        </tr>
                    </thead>
                    <tbody>
                        {foreach $ouList as $kk=>$vv}
                            {foreach $vv[0] as $k=>$v}
                            <tr class="C-{$v['size_name']}">
                            <td>{$v['client_ordernum']}</td>
                            <td>{$v['chuanghao']}</td>
                            <td>{$v['size_name']}</td>
                            <td>{$v['zhahao']}</td>
                            <td style="width:100px"><input type="text" data-id="{$v['mid']}"  name="jianshu[{$v['mid']}]" value="{$v['jianshu']}" autocomplete="off" class="layui-input edit" tabindex="{:$k+1}" lay-verify="required|number"></td>
                            {if condition="env('jinpeng_api_status') eq 1"}
	                            <td>{$v['jinpeng_qty']}</td>
	                            <td class="jinpengStatus{$v['mid']}">{:arrayGet($jinpengStatusKV,$v['jinpeng_status'],'')}</td>
	                            <td><a class='hisi-ajax blue ' refresh="false" href="{:url('delMcZha')}?mid={$v['mid']}" callback="updateCallback">删除</a>
	                                <a class='hisi-ajax blue' refresh="false" href="{:url('syncJinpengCut')}?mid={$v['mid']}&order_id={$v['order_id']}&action=edit" callback="updateCallback">同步金鹏</a></td>
	                            
	                            </tr>
                            {/if}
                            {/foreach}
                            <tr><td colspan="9"><input type="text" data-order-id="{$kk}"  value="{$vv[1]}" autocomplete="off" class="layui-input edit-remark" placeholder="请填写备注"></tr>
                        {/foreach}
                    </tbody>
                </table>
                {/if}
            </div>
            <input type="hidden" name="post_oddments_meters" id="post_oddments_meters" value="">
            <input type="hidden" name="post_storeHouse" id="storeHouse" value="">
            <input type="hidden" name="post_stock_position" id="post_stock_position" value="">
        </form>
    </div>
	{/if}
</div>
<div id="doneTpl" class="hide">
	<div class="layui-form-item pt20 pl20 layui-form">
    	<form class="layui-form" action="{:url('cutPackageLabelV2')}" method="get" target="_blank" id="form33">
            <div class="layui-inline">
                <label class="layui-form-label" style="padding:8px 5px;">打标包数：</label>
                <div class="layui-input-inline">
                    <input type="text" name="cut_packages" id="" value="{{d.cut_packages}}" lay-verify="number|required" placeholder="输入数量" class="layui-input cut_packages">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label" style="padding:8px 5px;">包备注：</label>
                <div class="layui-input-inline">
                    <input type="text" name="cut_packages_remark" id="" value=""  placeholder="包备注" maxlength="5" class="layui-input cut_packages_remark">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">工厂：</label>
                <div class="layui-input-inline factory_name">
    
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">分组：</label>
                <div class="layui-input-inline group_name">
    
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">外发工厂：</label>
                <div class="layui-input-inline factory_outgo_name">
    
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">外发地址：</label>
                <div class="layui-input-inline address">
    
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">电话：</label>
                <div class="layui-input-inline mobile">
    
                </div>
            </div>
            <input type="hidden" name="action" class="action" value="printr">
            <input type="hidden" name="order_id" class="order_id" value="">
            <div class="layui-inline fr">
              <button class="layui-btn" lay-submit lay-filter="done" >确认并打标</button>
            </div>
        </form>
	</div>
</div>
<div id="printrCutSizeLabelTpl" class="hide">
	<div class="layui-form-item pt20 pl20 layui-form">
		<form class="layui-form" action="{:url('cutSizeLabel')}" method="get" target="_blank" id="form33">
			{:FormExt::setInline('false')}
			<div class="layui-form-item">
				<label class="layui-form-label" style="padding:8px 5px;">选择扎号：</label>
				<div class="layui-input-inline" style="width:630px">
					<div id="cut_bars" class="cut_bars"></div>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label" style="padding:8px 5px;">包备注：</label>
				<div class="layui-input-inline" style="width:630px">
					<div id="packeg_remark" class="packeg_remark"></div>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label" style="padding:8px 5px;">打印订单：</label>
				<div class="layui-input-inline"  style="width:530px;padding:8px 5px;">
					{foreach $orderNumberArr as $k=>$v}
					<input type="checkbox" name="client_ordernum[]" lay-skin="primary" value="{if($is_cut_merge==0)}{$k}{else/}{$v}{/if}" lay-ignore checked="checked" />{$v} &nbsp;
					{/foreach}
				</div>
			</div>
			<div class="layui-form-item" style="display:none">
				<label class="layui-form-label" style="padding:8px 5px;">其它备注：</label>
				<div class="layui-input-inline mobile">
					<input type="text" name="other_remark" id="" value=""  placeholder="其它备注" maxlength="5" class="layui-input">
				</div>
			</div>
			<div style="text-align:center;color:#666666">打印扎菲前，需先完成 扎数信息，父窗口【编辑】按钮 可完成扎数信息</div>
			<input type="hidden" name="is_cut_merge" class="is_cut_merge" value="{$is_cut_merge}">
			<input type="hidden" name="action" class="action" value="printr">
			<input type="hidden" name="order_id" class="order_id" value="">
			<div class="layui-form-item" align="center" style="margin-top:40px;">
				<button class="layui-btn" lay-submit lay-filter="done" >确认并打印</button>
			</div>
		</form>
	</div>
</div>
<div id="cut_stage_tpl" class="hide">
    <form class="layui-form" action="{:url('cutPackageLabel')}" method="post" target="_blank" id="form33">
    	<input type="hidden" value="1" name="have_oddments" class="have_oddments" />
        <div class="layui-layer-btn layui-layer-btn-c">
        <button type="button" onclick="haveOddments(this,1)" class="layui-btn layui-btn-sm layui-btn-normal">有余料</button>
        <button type="button" onclick="haveOddments(this,0)" class="layui-btn layui-btn-sm layui-btn-primary">没有余料</button>
        </div>
        <div class="oddmentsInputForm">
        <div class="layui-inline">
            <label class="layui-form-label" style="padding:9px 2px;">余料米数：</label>
            <div class="layui-input-inline">
                <input type="text" name="oddments_meters" id="oddments_meters" value="0" lay-verify="float|required" placeholder="输入米数" class="layui-input oddments_meters">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label" style="padding:9px 2px;">存放仓库：</label>
            <div class="layui-input-inline">
                {:Form::select('storeHouse', '', $storeHouse, '', '', 'lay-filter="storehouse-id" lay-verify="required"')}
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label" style="padding:9px 2px;">货架号：</label>
            <div class="layui-input-inline">
            	{:Form::select('stock_position', '', [], '', '')}
            </div>
        </div>
        </div>
        <div style="text-align:center;padding:10px 5px;">
          <button class="layui-btn oddments_confirm_btn" lay-submit lay-filter="oddments_confirm_btn" >确认余料</button>
        </div><br />
<br />
<br />

    </form>
</div>

{include file="system@block/layui" /}
<script src="__PUBLIC_JS__/xm-select/dist/xm-select.js"></script>
<script>
    var demo1='',demo2='',formIndex=0;
    layui.use(['opTable', 'jquery','form','tool','layer'], function() {
        var $ = layui.jquery, form = layui.form,layer=layui.layer;
        var laytpl = layui.laytpl;
        var regFloat = /((^[1-9]\d*)|^0)(\.\d{0,2}){0,1}$/; // 浮点数，小数点后两位
        var regInt = /^\d+$/; // 整数
		var d = [];
		var oddmentslayer='';
        form.verify({
        	mimonumber: function(value, item){
        	    if (value=='') return '';
        	    if(! regFloat.test(value)){
        	    	return '只能填写数字';
        	    }
        	},
        
	        mimoint: function(value, item){
	    	    if (value=='') return '';
	    	    if(! regInt.test(value)){
	    	    	return '只能填写数字';
	    	    }
	    	}
        });
        form.on('submit(zhaEdit)', function (data) {       
            var formData = data.field,
            all_jian_count=data.field.all_jian_count,
            all_zha_count=data.field.all_zha_count,
            action=data.field.action;
            console.log(action);
            if(action=="add"){
                if(all_jian_count=="" || all_zha_count=="") {
                    layer.msg("总扎数或总件数未输入", {icon: 2,anim: 6});
                    return false;
                }
            }
            $.ajax({
                   type: "POST",
                   url: "{:url('editMcStrit')}",
                   data: formData,
                   dataType:"json",
                   success: function(res){
                        if (res.code == 1) {
                            layer.msg(res.msg, {icon: 1});
                            $("#demo1").click();
                        } else {
                             layer.msg(res.msg, {icon: 2,anim: 6});
                        }
                   }
                });
            return false;
        });
        form.on('submit(Submit222333)', function(data) {
            formindex=$(this).attr("formindex");
            var mid=$(this).attr("data-mid");
            var before_cut_total=parseFloat($("#before_cut_total"+mid).val()),cut_real_total=parseFloat($("#cut_real_total"+mid).val());
            //$('#formSubmit-'+mid).text("提交中...");
			var oddments_confirm=$("#oddments_confirm"+mid).val();
            if(before_cut_total-cut_real_total>10 && oddments_confirm=='none'){ //余料米数确认
                var content = $('#cut_stage_tpl').html();
                oddmentslayer = layer.open({
                    type: 1
                    ,shade: 0.3
					,area: ['380px', '460px'] //弹出框大小
                    ,offset: ['220px', '420px']
                    ,anim: parseInt(Math.random()*(6+1),10)
                    ,skin:'layui-layer-molv'
                    ,title:'余料确认-检测到有余料'
                    ,content: content
                });
				$(".oddments_meters").eq(1).val((before_cut_total-cut_real_total).toFixed(2));
                $(".oddments_confirm_btn").attr("data-mid",mid)
				 form.render();
                return false;
			}
            $.post("{:url('confirm')}?mid="+mid,data.field,function(res){
                if(res.code==1){
                    if(res.data['exception']==1){
                        layer.confirm(res.data['msg'], {
                            btn: ['知道了'],
                        },function(){
                            window.location.reload();
                        });
                    }else{
                        window.location.reload();
                    }
                    $('#formSubmit-'+mid).text(res.msg);

                }else{
                    $('#formSubmit-'+mid).text(res.msg);
                    $('#formSubmit-'+mid).css("background","#ff5722")
                    setTimeout(function() { $('#formSubmit-'+mid).text("拉布确认");$('#formSubmit-'+mid).css("background","rgb(30, 159, 255)"); }, 3000);
                    layer.confirm(res.msg, {
                        btn: ['知道了'],
                    });
                }

            });
            return false;
        });
        //余料弹层确认余料信息
        form.on('submit(oddments_confirm_btn)', function(data) {
            var mid=$(this).attr("data-mid");
            var formdata=data.field;
            $("#have_oddments"+mid).val(formdata["have_oddments"]);
            $("#oddments_meters"+mid).val(formdata["oddments_meters"]);
            $("#storeHouse"+mid).val(formdata["storeHouse"]);
            $("#stock_position"+mid).val(formdata["stock_position"]);
            $("#oddments_confirm"+mid).val(1);
            $("#oddments_confirm_result"+mid).html(formdata["have_oddments"]==1?'余料确认:有余料'+formdata["oddments_meters"]+'米':'余料确认:没有余料');
            layer.close(oddmentslayer);
			$(".submit222333").eq(formindex).click();
            return false;
        });
		
		var storeshelfMap = {:json_encode($storeshelfMap)};
        // 货仓下拉切换
    	form.on('select(storehouse-id)', function(data){
    		var optionArr = storeshelfMap[data.value];
    		var option = '';
    		for(var i in optionArr) {
    			option += '<option value="'+i+'">'+optionArr[i]+'</option>';
    		}
    		$("select[name=stock_position] option").remove();
    		$('select[name=stock_position]').append(option);
    		form.render();
    	});
		
         window.updateCallback = function(res) {
             //console.log(res);
             $("#demo1").click();
         }
		 window.haveOddments=function(tag,haveState){
		 	var btn_class='layui-btn-normal';
			$(tag).parent().find("button").removeClass("layui-btn-normal").addClass("layui-btn-primary")
		 	$(tag).removeClass("layui-btn-primary").addClass(btn_class);
			$(".have_oddments").eq(1).val(haveState);
			$(".oddmentsInputForm").eq(1).css("display",haveState==1?'':'none');
			if(haveState==0){
				$("select[name=storeHouse]").removeAttr("lay-verify");//lay-verify="required"
			}
		 }

		$('.printrCutPackageLabel').on('click',function(){ 
			var orderid=$(this).attr("orderid");
			$(".order_id").val(orderid);
			$.ajax({
			  type: "POST",
			  url: "{:url('cutPackageLabelV2')}",
			  data: "order_id="+orderid,
			  dataType:"json",
			  success: function(res){
				 if (res.code == 1) {
					var printrData=d=res.data;
					$(".cut_packages").val(d.cut_packages);
					$(".cut_packages_remark").val(d.cut_packages_remark);
					$(".factory_name").html(d.factory_name);
					$(".group_name").html(d.group_name);
					$(".factory_outgo_name").html(d.factory_outgo_name);
					 $(".address").html(d.group_address);
					 $(".mobile").html(d.group_mobile);
				 } else {
					layer.msg(res.msg, {icon: 2,anim: 6});
				 }
			  }
		   });	
			var content = $('#doneTpl').html();
			layerDone = layer.open({
				type: 1
				,shade: 0
				,offset: '100px'
				,anim: parseInt(Math.random()*(6+1),10)
				,skin:'layui-layer-molv'
				,title:'切片打标'
				,content: content
			});
		});

        $('.printrCutSizeLabel').on('click',function(){
            var orderid=$(this).attr("orderid");
            $(".order_id").val(orderid);
            $.ajax({
                type: "POST",
                url: "{:url('cutPackageLabelV2')}",
                data: "order_id="+orderid,
                dataType:"json",
                success: function(res){
                    if (res.code == 1) {
                        var printrData=d=res.data;

                    } else {
                        layer.msg(res.msg, {icon: 2,anim: 6});
                    }
                }
            });
            var content = $('#printrCutSizeLabelTpl').html();
            content=content.replace("cut_bars","cut_bars1");
            content=content.replace("packeg_remark","packeg_remark1");
            layerDone = layer.open({
                type: 1
                ,shade: 0.6
                ,area: ['790px', '450px']
                ,offset: '100px'
                ,anim: parseInt(Math.random()*(6+1),10)
                ,skin:'layui-layer-molv'
                ,title:'扎菲票打印'
                ,content: content
            });

            demo1 = xmSelect.render({
                el: '#cut_bars1',
                name:'cut_bars',
                autoRow: true,
                toolbar: {
                    show: true,
                    list: ['ALL', 'CLEAR']
                },
					filterable: true,
					data: {:json_encode($cut_zhahaos)}
			})

            demo2 = xmSelect.render({
                el: '#packeg_remark1',
                name:'packeg_remark',
                autoRow: true,
                toolbar: {
                    show: true,
                    list: ['ALL', 'CLEAR']
                },
                filterable: true,
                data: {:json_encode($packeg_remark)}
			})
        });

       $('.edit').on('change',function(){ 
           var val=$(this).val(),
           mid=$(this).attr("data-id");
           $.ajax({
                type: "POST",
                url: "{:url('singeEditMcZha')}",
                data: {
                    mid:mid,
                    jianshu:val
                },
                dataType:"json",
                success: function(res){
                     if (res.code == 1) {
                         $('.jinpengStatus'+mid).html("<span class='blue'>未同步</span>")
                         //$("#demo1").click();
                         //layer.msg(res.msg, {icon: 1});
                     } else {
                          layer.msg(res.msg, {icon: 2,anim: 6});
                     }
                }
            });
       });
       $('.edit-remark').on('change',function(){ 
           var val=$(this).val(),
           order_id=$(this).attr("data-order-id");
            $.ajax({
              type: "POST",
              url: "{:url('remark')}",
              data: "order_id="+order_id+"&remark="+val,
              dataType:"json",
              success: function(res){
                 if (res.code == 1) {
                    layer.msg(res.msg, {icon: 1});
                 } else {
                    layer.msg(res.msg, {icon: 2,anim: 6});
                 }
              }
           });
       });
       //存cookie总扎数和总件数
       $('.cookieSave').on('change',function(){ 
           var name=$(this).attr('cookie'),val=$(this).val();
           $.cookie(name, val, { expires: 7 });
       });
        var omc_id=$('#omc-id').val();
        if(omc_id!=""){
            var allZhaCount=$.cookie('allZhaCount'+omc_id),allJianCount=$.cookie('allJianCount'+omc_id);
            if(allZhaCount!=null){
                $('#allZhaCount').val(allZhaCount);
            }
            if(allJianCount!=null){
                $('#allJianCount').val(allJianCount);
            }
        }
    });
</script>